<?php
class Question extends AppModel{
	
	public  $validate = array();
	
	public $belongsTo  = array(
		'ParentQuestion' => array('className' => 'Question', 'foreignKey' => 'parent_id'),
		'QuestionType' => array('className' => 'QuestionType', 'foreignKey' => 'question_type_id'),
		'QuestionLevel' => array('className' => 'QuestionLevel', 'foreignKey' => 'question_level_id'),
		'User' => array('className' => 'User', 'foreignKey' => 'user_id')
	);
	
	public $hasMany = array(
		'ChildQuestion' => array('className' => 'Question', 'foreignKey' => 'parent_id'),
		'Answer' => array('className' => 'Answer', 'foreignKey' => 'question_id')
	);
	
	public function AddQuestionValidate(){
		$validate1 = array(
				'question_type_id'=> array(
					'rule'=>array('comparison', '!=', 0),
					'message'=> 'Please select question type'),
				'question_level_id'=>array(
					'rule'=>array('comparison', '!=', 0),
					'message'=> 'Please select question level'),
				'content' => array(
					'mustNotEmpty' => array(
						'rule' => 'notEmpty',
						'message'=> 'Please enter question content'),
					'mustBeLonger' => array(
						'rule' => array('minLength', 6),
						'message'=> 'Content must be greater than 5 characters'))
			);
		$this->validate=$validate1;
		return $this->validates();
	}
}
?>